home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / AppMaker 2.0b3 / Demo AppMaker 2.0b3 / Examples / pre-built AMReminder / PowerPlant / CAdd.cp < prev    next >
Encoding:
Text File  |  1995-10-05  |  5.6 KB  |  311 lines  |  [TEXT/MMCC]

  1. // CAdd.cp -- dialog methods
  2. // Created 10/5/95 4:49 PM by AppMaker
  3.  
  4. #include "CAdd.h"
  5.  
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LStdControl.h>
  10. #include <LTabGroup.h>
  11. #include <LEditField.h>
  12. #include <LView.h>
  13. #include <LRadioGroup.h>
  14. #include <PP_Messages.h>
  15. #include "CmdCodes.h"
  16.  
  17. #define PPob_AddID    201
  18. #define RidL_AddID    201
  19.  
  20. Boolean        CAdd::sIsRegistered = false;
  21.  
  22. //----------
  23. void
  24. CAdd::RegisterClass ()
  25. {
  26.     URegistrar::RegisterClass('Add ', (ClassCreatorFunc)CAdd::CreateAddStream);
  27.  
  28.     // register the pane classes we use
  29.  
  30.     sIsRegistered = true;
  31. }
  32.  
  33. //----------
  34. CAdd*
  35. CAdd::CreateAdd(
  36.     LCommander    *inSuperCommander)
  37. {
  38.     if (!sIsRegistered) {
  39.         RegisterClass ();
  40.     }
  41.     return ((CAdd *)LWindow::CreateWindow(PPob_AddID, inSuperCommander));
  42. }
  43.  
  44. //----------
  45. //    This is the function you register with URegistrar to create a
  46. //    CAdd from a resource
  47. CAdd*
  48. CAdd::CreateAddStream(
  49.     LStream    *inStream)
  50. {
  51.     return (new CAdd(inStream));
  52. }
  53.  
  54. //----------
  55. //    The default constructor does nothing.
  56. CAdd::CAdd()
  57. {
  58. }
  59.  
  60. //----------
  61. //    The read-from-stream constructor just reads a dialog object.
  62. CAdd::CAdd(
  63.     LStream    *inStream)
  64.         : LDialogBox(inStream)
  65. {
  66. }
  67.  
  68. //----------
  69. //    The destructor does nothing.
  70. CAdd::~CAdd()
  71. {
  72. }
  73.  
  74. //----------
  75. //    This member function gets called once the containment hierarchy that contains
  76. //    this pane has been built. It gives us a chance to get data members for
  77. //    interesting subviews, and to do other operations now that our subviews exist.
  78. void
  79. CAdd::FinishCreateSelf()
  80. {
  81.     LDialogBox::FinishCreateSelf();
  82.  
  83.     mOKButton = (LStdButton *)FindPaneByID('OK  ');
  84.     mCancelButton = (LStdButton *)FindPaneByID('Canl');
  85.     mDateField = (LEditField *)FindPaneByID('Dat2');
  86.     mTimeField = (LEditField *)FindPaneByID('Tim2');
  87.     mAmPmView = (LView *)FindPaneByID('AMPM');
  88.     mMessageField = (LEditField *)FindPaneByID('Msg ');
  89.     mDisplayIconCheck = (LStdCheckBox *)FindPaneByID('Icon');
  90.     mDisplayAlertCheck = (LStdCheckBox *)FindPaneByID('Alrt');
  91.     mPlaySoundCheck = (LStdCheckBox *)FindPaneByID('Play');
  92.     mSoundPopup = (LStdPopupMenu *)FindPaneByID('Soun');
  93.  
  94.     mAmPmGroup = new LRadioGroup();
  95.     mAmPmGroup->AddRadio((LStdRadioButton *)mAmPmView->FindPaneByID(1));
  96.     mAmPmGroup->AddRadio((LStdRadioButton *)mAmPmView->FindPaneByID(2));
  97.  
  98.     LTabGroup    *tabGroup = new LTabGroup(this);
  99.     mDateField->SetSuperCommander(tabGroup);    // becomes the active field
  100.     mTimeField->SetSuperCommander(tabGroup);
  101.     mMessageField->SetSuperCommander(tabGroup);
  102.  
  103.     UReanimator::LinkListenerToControls(this, this, RidL_AddID);
  104.         // the purpose is to "connect" self to whatever controls
  105.         // that we want to "listen" to
  106.  
  107. // any additional initialization for your dialog:
  108.  
  109. }
  110.  
  111. //----------
  112. void
  113. CAdd::ListenToMessage(
  114.     MessageT    inMessage,
  115.     void        *ioParam)
  116. {
  117.     switch (inMessage) {
  118.     case msg_OK:
  119.             GetSuperCommander()->ProcessCommand(cmd_Add, this);
  120.         break;
  121.  
  122.     case msg_Cancel:
  123.             DoClose();
  124.         break;
  125.  
  126.     default:
  127.         break;
  128.     }
  129. }
  130.  
  131. //----------
  132. Boolean
  133. CAdd::ObeyCommand(
  134.     CommandT    inCommand,
  135.     void        *ioParam)
  136. {
  137.     Boolean        cmdHandled = true;
  138.  
  139.     switch (inCommand) {
  140.  
  141.     // +++ Add cases here for the commands you handle
  142.     //        Remember to add same cases to FindCommandStatus below
  143.     //        to enable/disable the commands
  144.  
  145.     default:
  146.             cmdHandled = LDialogBox::ObeyCommand(inCommand, ioParam);
  147.         break;
  148.     }
  149.  
  150.     return cmdHandled;
  151. }
  152.  
  153. //----------
  154. void
  155. CAdd::FindCommandStatus(
  156.     CommandT    inCommand,
  157.     Boolean        &outEnabled,
  158.     Boolean        &outUsesMark,
  159.     Char16        &outMark,
  160.     Str255        outName)
  161. {
  162.     outUsesMark = false;
  163.  
  164.     switch (inCommand) {
  165.  
  166.     // +++ Add cases here for the commands you handle
  167.  
  168.     default:
  169.             LDialogBox::FindCommandStatus(inCommand, outEnabled,
  170.                                             outUsesMark, outMark, outName);
  171.         break;
  172.     }
  173. }
  174.  
  175. //----------
  176. Boolean
  177. CAdd::FocusDraw()
  178. {
  179.     Boolean        focused = LView::FocusDraw();
  180.  
  181.     if (focused) {
  182.         AuxWinHandle    awHndl;
  183.         CTabHandle        awCTable;
  184.         ColorSpec        contentSpec;
  185.  
  186.         GetAuxWin(GetMacPort(), &awHndl);
  187.         awCTable = (**awHndl).awCTable;
  188.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  189.         ::RGBBackColor(&contentSpec.rgb);
  190.     }
  191.  
  192.     return focused;
  193. }
  194.  
  195. //----------
  196. void
  197. CAdd::GetDateFieldString        (Str255        str)
  198. {
  199.     mDateField->GetDescriptor(str);
  200. }
  201.  
  202. //----------
  203. void
  204. CAdd::SetDateFieldString        (Str255        str)
  205. {
  206.     mDateField->SetDescriptor(str);
  207. }
  208.  
  209. //----------
  210. void
  211. CAdd::GetTimeFieldString        (Str255        str)
  212. {
  213.     mTimeField->GetDescriptor(str);
  214. }
  215.  
  216. //----------
  217. void
  218. CAdd::SetTimeFieldString        (Str255        str)
  219. {
  220.     mTimeField->SetDescriptor(str);
  221. }
  222.  
  223. //----------
  224. long
  225. CAdd::GetAmPmGroupChoice()
  226. {
  227.     return mAmPmGroup->GetCurrentRadioID();
  228. }
  229.  
  230. //----------
  231. void
  232. CAdd::SetAmPmGroupChoice        (long        choice)
  233. {
  234.     LControl    *theControl = (LControl *)mAmPmView->FindPaneByID(choice);
  235.  
  236.     if (theControl != nil) {
  237.         theControl->SetValue(Button_On);
  238.     }
  239. }
  240.  
  241. //----------
  242. void
  243. CAdd::GetMessageFieldString        (Str255        str)
  244. {
  245.     mMessageField->GetDescriptor(str);
  246. }
  247.  
  248. //----------
  249. void
  250. CAdd::SetMessageFieldString        (Str255        str)
  251. {
  252.     mMessageField->SetDescriptor(str);
  253. }
  254.  
  255. //----------
  256. Boolean
  257. CAdd::GetDisplayIconCheckChoice()
  258. {
  259.     return mDisplayIconCheck->GetValue();
  260. }
  261.  
  262. //----------
  263. void
  264. CAdd::SetDisplayIconCheckChoice        (Boolean    choice)
  265. {
  266.     mDisplayIconCheck->SetValue(choice);
  267. }
  268.  
  269. //----------
  270. Boolean
  271. CAdd::GetDisplayAlertCheckChoice()
  272. {
  273.     return mDisplayAlertCheck->GetValue();
  274. }
  275.  
  276. //----------
  277. void
  278. CAdd::SetDisplayAlertCheckChoice        (Boolean    choice)
  279. {
  280.     mDisplayAlertCheck->SetValue(choice);
  281. }
  282.  
  283. //----------
  284. Boolean
  285. CAdd::GetPlaySoundCheckChoice()
  286. {
  287.     return mPlaySoundCheck->GetValue();
  288. }
  289.  
  290. //----------
  291. void
  292. CAdd::SetPlaySoundCheckChoice        (Boolean    choice)
  293. {
  294.     mPlaySoundCheck->SetValue(choice);
  295. }
  296.  
  297. //----------
  298. short
  299. CAdd::GetSoundPopupChoice()
  300. {
  301.     return mSoundPopup->GetValue();
  302. }
  303.  
  304. //----------
  305. void
  306. CAdd::SetSoundPopupChoice        (short        choice)
  307. {
  308.     mSoundPopup->SetValue(choice);
  309. }
  310.  
  311.